﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Bai1
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        int a;
        int b;
        public MainWindow()
        {
            InitializeComponent();
        }

        private void Tong_Click(object sender, RoutedEventArgs e)
        {
            a = Convert.ToInt32(txta.Text);
            b = Convert.ToInt32(txtb.Text);
            txtTong.Text = Convert.ToString(a + b);
        }

        private void Tru_Click(object sender, RoutedEventArgs e)
        {
            a = Convert.ToInt32(txta.Text);
            b = Convert.ToInt32(txtb.Text);
            txtTong.Text = Convert.ToString(a - b);
            MessageBox.Show("Có cái này cũng phải dùng máy tính zốt zốt");
        }

        private void Nhan_Click(object sender, RoutedEventArgs e)
        {
            a = Convert.ToInt32(txta.Text);
            b = Convert.ToInt32(txtb.Text);
            txtTong.Text = Convert.ToString(a * b);
        }

        private void Chia_Click(object sender, RoutedEventArgs e)
        {
            float a = float.Parse(txta.Text);
            float b = float.Parse(txtb.Text);
            if (b == 0)
            {
                MessageBox.Show("Nghĩ sao vậy???");
            }
            else
            txtTong.Text = Convert.ToString(a / b);
        }

        private void Reset_Click(object sender, RoutedEventArgs e)
        {
            txta.Text = "";
            txtb.Text = "";
            txtTong.Text = "";
            txta.Focus();
            
        }

        private void Thoat_Click(object sender, RoutedEventArgs e)
        {
            MessageBoxResult Result = MessageBox.Show("Thoat thi thoat hoi lam gi?","Thông Báo",MessageBoxButton.YesNo,MessageBoxImage.Warning);
            if (Result == MessageBoxResult.Yes)
            {
                this.Close();
            }
        }
    }
}
